/*
 * FriendRewardResource.h
 *
 *  Created on: 2013. 9. 6.
 *      Author: mega@gamevil.com
 */

#ifndef FRIENDREWARDRESOURCE_H_
#define FRIENDREWARDRESOURCE_H_

#include <map>
#include "../engine.h"

namespace ProjectZ { namespace NResource {

class FriendRewardData
{
public:
	struct Key
	{
		Key() : type(0), sub_type(0) {}
		Key(int rType, int rSubType) : type(rType), sub_type(rSubType) {}

		int type;
		int sub_type;

		bool operator == (const Key & rSide) const
		{
			if (this->type == rSide.type && this->sub_type == rSide.sub_type)
				return true;

			return false;
		}

		bool operator < (const Key & rSide) const
		{
			if (this->type < rSide.type)
			{
				return true;
			}
			else if (this->type == rSide.type)
			{
				if (this->sub_type < rSide.sub_type)
					return true;
			}

			return false;
		}
	};

public:
	struct Flyweight
	{
		int _TYPE;
		int _SUB_TYPE;
		int _FRIEND_CNT;
		int _ITEM_TID;
		int _ITEM_SHEET;
		int _VALUE;
		Toolkit::Str<255> _IMG_URL_DEFAULT;
		Toolkit::Str<255> _IMG_URL;
	};

public:
	FriendRewardData() {};
	virtual ~FriendRewardData();

	bool LoadResource(int company, int saleCode);
	Flyweight * GetFly(Key & clsKey);

private:
	typedef std::map<Key, Flyweight *>	DATATREE;
	DATATREE	clsFlyTree;
};


class FriendRewardResource
{
public:
	FriendRewardResource();
	virtual ~FriendRewardResource();

	bool LoadResource();
	FriendRewardData::Flyweight * GetFly(int company, int saleCode, FriendRewardData::Key & clsKey);

private:
	FriendRewardData * pFriendRewardAndroid;
	FriendRewardData * pFriendRewardIOS;
};

} /* NResource */ } /* ProjectZ */


#endif /* FRIENDREWARDRESOURCE_H_ */
